package vue;


import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

import modele.CSV;
import controleur.AddListener;
import controleur.DelListener;
import controleur.List2Listener;
import controleur.List3Listener;
import controleur.List1Listener;

public class AddressBook extends JFrame{
	
	
	 private JButton add; 
	 private JButton del; 
	 private JButton list1;
	 private JButton list2;
	 private JButton list3;
	 
	 public static final String FIRSTNAME = "First Name";
	 public static final String LASTNAME = "Last Name";
	 public static final String HOME = "Home Address";
	 public static final String COMPANY = "Company Address";
	 public static final String PERS = "Personal Phone";
	 public static final String PRO = "Professional Phone";
	 public static final String PAGE = "Home Page";
	 public static final String EMAIL = "Email";
	 public static final String PHOTO = "Photo";
	 public static final String GROUP = "Group";
	 public static final String LISTOFCONTACTS ="List of contacts";
	 public static final String MODIFY ="Modify";
	 public static final String SAVEUPDATES ="Save updates";
	 public static final String FAMILY ="Family";
	 public static final String FRIEND ="Friend";
	 public static final String WORK ="Work";
	 public static final String ADD ="Add Contact";
	 public static final String DEL ="Delete Contact";
	 public static final String L1 ="Contacts per entering order";
	 public static final String L2 ="Contacts per alphabetical order";
	 public static final String L3 ="Contacts per groups";
	
	 
	 /**
	  * Constructor
	  */
	 public AddressBook(){
		 this.setSize(1000, 120);
		 this.setTitle("Address Book");
		 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		 this.setLocationRelativeTo(null);	 
		 this.setResizable(false);
		 JPanel pan = new JPanel();
		 init(pan);
		 this.setContentPane(pan);    
		 this.setVisible(true);
		 CSV.loadContacts();
		
	 }
	 
	 /**
	  * initialize graphic components
	  * @param pan
	  */
	 private void init(JPanel pan){
		 
		 add = new JButton(AddressBook.ADD);
		 del = new JButton(AddressBook.DEL);
		 list1 = new JButton(AddressBook.L1);
		 list2 = new JButton(AddressBook.L2);
		 list3 = new JButton(AddressBook.L3);
		 add.addActionListener(new AddListener());
		 del.addActionListener(new DelListener());
		 list1.addActionListener(new List1Listener());
		 list2.addActionListener(new List2Listener());
		 list3.addActionListener(new List3Listener());
		 pan.add(add);
		 pan.add(del);
		 pan.add(list1);
		 pan.add(list2);
		 pan.add(list3);
		
	 }
	 

}
